package semaphore

var balance int

var sema = make(chan struct{}, 1) // a binary semaphore guarding balance

//Deposit save money to bank
func Deposit(amount int) {
	sema <- struct{}{}
	balance = balance + amount
	<-sema
}

//Balance check money in bank
func Balance() int {
	sema <- struct{}{}
	b := balance
	<-sema
	return b
}
